#pragma once

//#include <vld.h>

#include "clkHeader.h"
#include "clkBody.h"
#include "clkShape.h"

#define RECT(x) ((clkRect*)x)
#define CIRC(x) ((clkCircle*)x)

class clkObject
{
public:
	//attributes
	clkAABB m_aabb;
	clkBody* m_body;
	clkShape* m_shape;

	//ctor & dtor
	clkObject();
	~clkObject();

	//main functions
	void destroy();
	void update();

	//world functions
	void applyLinearForce(V2DF a_force)
	{m_body->m_lnForce += a_force;}

	void applyAngularForce(float a_force)
	{m_body->m_agForce += a_force;}

	void setPosition(V2DF a_position);
	void setRotation(float a_rotation);

	void setLinearVelocity(V2DF a_lnVelocity)
	{m_body->m_lnVelocity = a_lnVelocity;}

	void setAngularVelocity(float a_agVelocity)
	{m_body->m_agVelocity = a_agVelocity;}

	void setLinearForce(V2DF a_force)
	{m_body->m_lnForce = a_force;}

	void setAngularForce(float a_force)
	{m_body->m_agForce = a_force;}

	//body functions
	V2DF&  refPosition(){return m_body->m_position;}
	V2DF&  refLinearVelocity(){return m_body->m_lnVelocity;}
	float& refLinearAngular(){return m_body->m_agVelocity;}
	V2DF&  refLinearForce(){return m_body->m_lnForce;}
	float& refAngularForce(){return m_body->m_agForce;}

	V2DF  getPosition(){return m_body->m_position;}
	float getRotation(){return m_body->m_rotation;}
	float getMass(){return m_body->m_mass;}
	float getInertia(){return m_body->m_inertia;}

	V2DF  getLinearVelocity(){return m_body->m_lnVelocity;}
	float getAngularVelocity(){return m_body->m_agVelocity;}
	float getLinearDamping(){return m_body->m_lnDamping;}
	float getAngularDamping(){return m_body->m_agDamping;}
	V2DF  getLinearForce(){return m_body->m_lnForce;}
	float getAngularForce(){return m_body->m_agForce;}
	float getMaxLinearForce(){return m_body->m_maxLnForce;}
	float getMaxAngularForce(){return m_body->m_maxAgForce;}

	bool isCollidable(){return m_body->m_collidable;}
	bool isStatic(){return m_body->m_static;}

	//shape functions
	int getType(){return m_shape->m_type;}
	V2DF getDir(){return m_shape->m_dir;}
	float getWidth();
	float getHeight();
	int getVertCount();
	V2DF* getRVerts();
	V2DF* getAVerts();
	V2DF* getNorms();
};